﻿using SuperSocket.SocketBase.Command;
using SuperSocket.SocketBase.Protocol;
using superSocketDemo.Client;
using superSocketDemo.info;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace superSocketDemo.Command
{

    /// <summary>
    /// 登陆命令
    /// </summary>
    public class Logn : CommandBase<SocketClientSession, MyRequestInfo>
    {
        /// <summary>
        /// 执行命令
        /// </summary>
        /// <param name="session"></param>
        /// <param name="requestInfo"></param>
        public override void ExecuteCommand(SocketClientSession session, MyRequestInfo requestInfo)
        {
            if (requestInfo.Key == "Login")
            {
                //var oldSession = session.AppServer.GetAllSessions().Where(x => x.Id == session.Id).FirstOrDefault();
                //if (oldSession.IsLogin)
                //{
                //    oldSession.Send("you kick out");
                //    oldSession.Close();
                //}
                string str = System.Text.Encoding.Default.GetString(requestInfo.Body);
                //session.Id = Convert.ToInt16(requestInfo.Parameters[0]);
                //session.Name = requestInfo.Parameters[1];
                //session.IsLogin = true;
                //Console.WriteLine($"id:{session.Id}is login!");
            }
            
        }
    }
}
